package com.example.wanandroid1

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.wanandroid1.databinding.ActivityRegisterBinding

class RegisterActivity : AppCompatActivity() {
    private lateinit var binding: ActivityRegisterBinding
    val accountList = mutableListOf<String>()
    val passwordList = mutableListOf<String>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityRegisterBinding.inflate(layoutInflater)
        setContentView(binding.root)
        with(binding) {
            val account = etRgAccount.text
            val password = etRgPassword.text
            accountList.add(account.toString())
            passwordList.add(password.toString())
            tvSet.setOnClickListener {
                val editor = getSharedPreferences("data", Context.MODE_PRIVATE).edit()
                editor.putString("account", "$account")
                editor.putString("password", "$password")
                editor.apply()
                Log.d("hhhhaccount", "$account")
                Log.d("hhhhpassword", "$password")
                Toast.makeText(this@RegisterActivity, "register successfully!", Toast.LENGTH_SHORT)
                    .show()
            }
        }
    }
}